package com.javabasic.interview_4399;

import java.util.Scanner;

/**
 * @Author xiongmin
 * @Description TODO
 * @Date 2019/10/11 19:41
 * @Version 1.0
 **/
public class ThreeProblem {
    static Scanner cin = new Scanner(System.in);
    static int[] mon = new int[]{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    public static void main(String[] args) {
        String targetDay = cin.next();
        String[] targetDate = targetDay.split(",");
        int year = Integer.parseInt(targetDate[0]),
                month = Integer.parseInt(targetDate[1]),
                day = Integer.parseInt(targetDate[2]);
        if (year > 2016) {
            if (caculate1(year, month, day)) {
                System.out.println("休息");
            } else {
                System.out.println("不休息");
            }
        } else if (year < 2016) {
            if (caculate2(year, month, day)) {
                System.out.println("休息");
            } else {
                System.out.println("不休息");
            }
        } else {
            if (caculate3(year, month, day)) {
                System.out.println("休息");
            } else {
                System.out.println("不休息");
            }
        }
    }

    /**
     * 返回值为true表示可以休息，false表示不可以休息
     *
     * @param year
     * @param month
     * @param day
     * @return
     */
    // 大于2016年
    public static boolean caculate1(int year, int month, int day) {
        int days = day;
        for (int i = 2017; i < year; i++) {
            if (isPrimeYear(i)) {
                days += 266;
            } else {
                days += 365;
            }
        }
        for (int i = 1; i < month; i++) {
            days += mon[i];
        }
        days += getThisYearDays(2016, 8, 15);
        return isResult(days);
    }

    /**
     * 获取指定日子到年底的时间
     *
     * @param year
     * @param month
     * @param day
     * @return
     */
    private static int getThisYearDays(int year, int month, int day) {
        int days = mon[month] - day + 1;
        for (int i = month + 1; i < 13; i++) {
            days += mon[i];
        }
        return days;

    }

    private static boolean isPrimeYear(int year) {
        if (year % 400 == 0 || year % 100 != 0 && year % 4 == 0) return true;
        return false;

    }

    // 小于2016年
    public static boolean caculate2(int year, int month, int day) {
        int days = getThisYearDays(year, month, day);
        for (int i = year + 1; i < 2016; i++) {
            if (isPrimeYear(i)) {
                days += 366;
            } else {
                days += 365;
            }
        }
        days += 366 - getThisYearDays(2016, 8, 15);
        return isResult2(days);
    }

    // 等于2016年
    public static boolean caculate3(int year, int month, int day) {
        int days = getThisYearDays(year, month, day);
        int num = getThisYearDays(2016, 8, 15);
        if (days > num) {
            days = days - num;
            return isResult2(days);
        } else {
            days = num - days + 1;
            return isResult(days);
        }

    }

    private static boolean isResult(int days) {
        boolean result;
        if (days % 7 == 0) {
            result = true;
        } else if (days % 7 == 6) {
            int num = days / 7;
            if (num % 2 == 1) {
                result = true;
            } else {
                result = false;
            }
        } else {
            result = false;
        }
        return result;
    }

    private static boolean isResult2(int days) {
        boolean result;
        if (days % 7 == 1) {
            result = true;
        } else if (days % 7 == 2) {
            int num = days / 7;
            if (num % 2 == 0) {
                result = true;
            } else {
                result = false;
            }
        } else {
            result = false;
        }
        return result;
    }
}
